package com.netty.tcp;

import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.util.concurrent.EventExecutorGroup;
import lombok.extern.slf4j.Slf4j;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;

@Slf4j
public class ServerHandler extends ChannelInboundHandlerAdapter {


    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        //super.channelRead(ctx, msg);
        MsgObj obj = (MsgObj) msg;
      //  log.info("收到报文：[{}]",obj);
        Document doc = DocumentHelper.parseText(obj.getBody());
       // log.info("[{}]",doc.asXML());
        obj.setBody(obj.getBody()+"|");
        ctx.writeAndFlush(obj);
    }
}
